package HousingService.task2.serialization.db_exschange;

import HousingService.task3.dao.HsAddressDao;
import HousingService.task3.factory.HsAddressDaoFactory;

import java.io.*;

/**
 * Created by IntelliJ IDEA.
 * User: Linderhof
 * Date: 03.12.2010
 * Time: 15:12:45
 */
public class ExportDemo {
    public static void main(String[] args) {
        HsAddressDao dao = HsAddressDaoFactory.create();
        Exporter exporter = new Exporter();
        exporter.export(dao);

        System.out.println("Exported file:\n");
        displayFile(exporter.getDefaultExportFile());

    }

     private static void displayFile(File file) {
        FileReader reader = null;
        BufferedReader in = null;

        try {
            reader =  new FileReader(file);
            in = new BufferedReader(reader);
            String line;
            while((line = in.readLine()) != null) {
                System.out.println(line);
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
        finally {
            if(in != null) {
                try {
                    in.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }

    }
}
